from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

from . import views

urlpatterns = [
    url(r"username/(?P<username>\w{5,20})/count/$",
        views.UsernameCountView.as_view()),
    url(r'mobile/(?P<mobile>1[3-9]\d{9})/count/$',
        views.MobileCountView.as_view()),
    url(r'users/$', views.UserView.as_view()),
    # Django REST framework JWT中提供了签发JWT的视图,但返回的只有token
    # url(r'authorizations/$', obtain_jwt_token),
    url(r'authorizations/$', views.UserAuthorizeView.as_view()),
    url(r'^user/$', views.UserDetailView.as_view()),  # 个人中心基本信息
    url(r'email/$', views.EmailView.as_view()),  # 设置邮箱
    url(r'^emails/verification/$', views.VerifyEmailView.as_view()),  # 验证邮箱
    url(r'browse_histories/$', views.UserBrowsingHistoryView.as_view())
]

router = DefaultRouter()
router.register("addresses", views.AddressViewSet, base_name="addresses")
urlpatterns += router.urls
